Rest-API
The TimePunch Rest API can be used to easily connect to third-party systems. TimePunch offers extensive possibilities for data analysis via the Rest-API interface.
Example in PHP
Here is a simple example of how the Rest API interface in PHP can be used to load the monthly analyses.
<?php
// Method: POST, PUT, GET etc
// Data: array("param" => "value") ==> index.php?param=value
function CallAPI(\$url, \$data = false, \$username, \$password)
{
\$curl = curl_init();
if (\$data)
\$url = sprintf("%s?%s", \$url, http_build_query(\$data));
// Optional Authentication:
curl_setopt(\$curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(\$curl, CURLOPT_USERPWD, "\$username:\$password");
curl_setopt(\$curl, CURLOPT_URL, \$url);
curl_setopt(\$curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(\$curl, CURLOPT_SSL_VERIFYPEER, false);
\$result = curl_exec(\$curl);
curl_close(\$curl);
return json_decode(\$result);
}
// Get data from the API
\$username = "ralf.herrmann";
\$password = "tpdemo";
\$data = CallAPI("https://demo.timepunch-hub.com/bi/api/MonthlySummaries", array(
"users" => "svenja.rabe"
), \$username, \$password);
var_dump(\$data);
?>
API Reference
TimePunch provides the following API commands.
Get api/ProjectTimes
Returns all time entries related to a specific project or to selected projects.
Request Information
GET api/ProjectTimes?users={users}&projects={projects}&customers={customers}&logon={logon}&logoff={logoff}&important={important}&onsite={onsite}¬Invoiced={notInvoiced}
Name | Description | Type |
---|---|---|
users | search for users that are connected by a + sign | string |
projects | search for projects that are connected by a + sign | string |
customers | search for customers that are connected by a + sign | string |
logon | first date that is returned | string |
logoff | last date that is returned | string |
important | if set to true, only important entries will be returned | boolean |
onsite | if set to true, only on-site entries will be returned | boolean |
notInvoiced | if set to true, only not invoiced entries will be returned | boolean |
RESPONSE Information
This method returns objects of type ReportTimeEntryDto.
Get api/UserTimes
Returns all time entries related to specific users or to the selected users.
Request Information
GET api/UserTimes?users={users}&projects={projects}&customers={customers}&logon={logon}&logoff={logoff}&important={important}&onsite={onsite}¬Invoiced={notInvoiced}&showWorkingTime={showWorkingTime}&showBreaks={showBreaks}&showPublicHolidays={showPublicHolidays}&showWeekends={showWeekends}&showMissingdays={showMissingdays}&showWeekdays={showWeekdays}
Name | Description | Type |
---|---|---|
users | search for users that are connected by a + sign | string |
projects | search for projects that are connected by a + sign | string |
customers | search for customers that are connected by a + sign | string |
logon | first date that is returned | string |
logoff | last date that is returned | string |
important | if set to true, only important entries will be returned | boolean |
onsite | if set to true, only on-site entries will be returned | boolean |
notInvoiced | if set to true, only not invoiced entries will be returned | boolean |
showWorkingTime | if set to true, working times are returned (default is true) | boolean |
showBreaks | if set to true, break times are returned (default is true) | boolean |
showPublicHolidays | if set to true, public holiday are returned (default is true) | boolean |
showWeekends | if set to true, weekends are returned (default is false) | boolean |
showMissingdays | if set to true, missing days are returned (default is false) | boolean |
showWeekdays | if set to true, weekdays are returned (default is false) | boolean |
RESPONSE Information
This method returns objects of type ReportTimeEntryDto.
Get api/Users
Returns the master data of one or more selected users.
Request Information
GET api/Users?search={search}&isDeleted={isDeleted}
Name | Description | Type |
---|---|---|
search | search for user names that are connected by a + sign | string |
isDeleted | true, if only deleted users shall be searched | boolean |
RESPONSE Information
This method returns objects of type ReportUserDTO.
Get api/Projects
Returns the master data of one or more selected projects.
Request Information
Name | Description | Type |
---|---|---|
search | search for projects that are connected by a + sign | string |
lifeCylce | search for projects that are in a special state (0 = all, 1 = planning, 2 = active, 4 = done, 8 = deleted) | integer |
withTasks | true, if also depending tasks shall be returned | boolean |
userDefinedCustomers | true, if also used defined customers shall be returned | boolean |
RESPONSE Information
This method returns objects of type ReportProjectDTO.
Get api/Customers
Returns the master data of one or more selected customers.
Request Information
Name | Description | Type |
---|---|---|
search | search for customer names that are connected by a + sign | string |
isDeleted | true, if only deleted customers shall be searched | boolean |
RESPONSE Information
This method returns objects of type ReportCustomerDTO.
Get api/DailySummaries
Returns the aggregated daily values of one or more selected employees within a defined time period.
Request Information
Name | Description | Type |
---|---|---|
users | search for users that are connected by a + sign | string |
logon | first date that is returned | string |
logoff | last date that is returned | string |
RESPONSE Information
This method returns objects of type ReportDailySummaryDTO.
Get api/MonthlySummaries
Returns the aggregated monthly values of one or more selected employees within a defined period.
Request Information
Name | Description | Type |
---|---|---|
users | search for users that are connected by a + sign | string |
logon | first month that is returned | string |
logoff | last month that is returned | string |
RESPONSE Information
This method returns objects of type ReportSummaryDTO.
Get api/YearlySummaries
Returns the aggregated annual values of one or more selected employees within a defined period.
Request Information
Name | Description | Type |
---|---|---|
users | search for users that are connected by a + sign | string |
logon | first year that is returned | string |
logoff | last year that is returned | string |
RESPONSE Information
This method returns objects of type ReportYearlySummaryDTO.
Get api/DailyProjectTimes
This method returns the project times aggregated to daily values.
Request Information
Name | Description | Type |
---|---|---|
search | search for projects that are connected by a + sign | string |
lifeCylce | search for projects that are in a special state (0 = all, 1 = planning, 2 = active, 4 = done, 8 = deleted) | integer |
RESPONSE Information
This method returns objects of type ReportProjectTimeDto.